home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / V2T1HL (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  1.9 KB  |  42 lines

  1. package com.sun.java.swing.text;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Point;
  5. import java.awt.Rectangle;
  6. import java.awt.event.ActionEvent;
  7.  
  8. class DefaultEditorKit$DownAction extends TextAction {
  9.    private boolean select;
  10.  
  11.    DefaultEditorKit$DownAction(String nm, boolean select) {
  12.       super(nm);
  13.       this.select = select;
  14.    }
  15.  
  16.    public void actionPerformed(ActionEvent e) {
  17.       JTextComponent target = ((TextAction)this).getTextComponent(e);
  18.       if (target != null) {
  19.          try {
  20.             Caret caret = target.getCaret();
  21.             int dot = caret.getDot();
  22.             Point p = caret.getMagicCaretPosition();
  23.             if (p == null) {
  24.                Rectangle r = target.modelToView(dot);
  25.                p = new Point(r.x, r.y);
  26.                caret.setMagicCaretPosition(p);
  27.             }
  28.  
  29.             dot = Utilities.getPositionBelow(target, dot, p.x);
  30.             if (this.select) {
  31.                caret.moveDot(dot);
  32.             } else {
  33.                caret.setDot(dot);
  34.             }
  35.          } catch (BadLocationException var7) {
  36.             ((Component)target).getToolkit().beep();
  37.          }
  38.       }
  39.  
  40.    }
  41. }
  42.